/*
 * BasePropertyEditorJPanel.java
 *
 * Created on 30 mei 2007, 9:14
 */

package net.jwtools.tmt.ui.propertyeditor;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import net.jwtools.tmt.service.Filter;

import com.l2fprod.common.swing.LookAndFeelTweaks;

/**
 * 
 * @author naftali
 */
public class TerritoryPropertyEditorJPanel extends BasePropertyEditorJPanel {

	public TerritoryPropertyEditorJPanel() {
		super();
		initProperties();

		// TODO uit UserPreferences (singleton) uit de database halen
		// filterMap = UserPreferences.get("filterMap") = null > defaultMap
		// zetten en opslaan in UserPreferences
		// setMap(filterMap)
		// setDefault(UserPreferences.get("defaultfilter"))

	}

	public static void main(String[] args) {
		JFrame j = new JFrame();
		j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (IllegalAccessException ex) {
			ex.printStackTrace();
		} catch (ClassNotFoundException ex) {
			ex.printStackTrace();
		} catch (InstantiationException ex) {
			ex.printStackTrace();
		} catch (UnsupportedLookAndFeelException ex) {
			ex.printStackTrace();
		}
		LookAndFeelTweaks.tweak();

		TerritoryPropertyEditorJPanel p = new TerritoryPropertyEditorJPanel();

		p.loadDummyData();
		j.getContentPane().add(p);
		j.pack();
		j.setVisible(true);
	}

	void initProperties() {
		ExtendedProperty p = new ExtendedProperty();
		p.setName("territoryTypeRegular");
		p.setType(Boolean.class);
		p.setDisplayType(Boolean.class);
		p.setCategory("Territory");
		p.setDisplayName("Regular");
		p.setValue(Boolean.TRUE);
		getPropertySheet().addProperty(p);

		p = new ExtendedProperty();
		p.setName("territoryTypeNotHome");
		p.setType(Boolean.class);
		p.setDisplayType(Boolean.class);
		p.setCategory("Territory");
		p.setDisplayName("Not home");
		p.setValue(Boolean.TRUE);
		getPropertySheet().addProperty(p);

		p = new ExtendedProperty();
		p.setName("person");
		p.setType(String.class);
		p.setDisplayType(ArrayList.class);
		p.setCategory("Checked out by");
		p.setDisplayName("Person");
		p.setValue("Naftali van der Loon");
		// getallactivepersons
		p.setAllowedValues(new String[] { "Naftali van der Loon",
						"Pieter Pauw" });
		getPropertySheet().addProperty(p);

	}

	void loadDummyData() {
		final Filter standaardZoekFilter = new Filter(
				bundle.getString("default.filter.name"));
		standaardZoekFilter.setStatus("Voorraad AH");

		Map filterMap = new HashMap();
		filterMap.put(standaardZoekFilter.getName(), standaardZoekFilter);
		setDefault(standaardZoekFilter);
		setMap(filterMap);

	}

}
